// components/analysis-steps/analysisSteps.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    stepIndex: Number,
    customerId: String,
    productId: String,
    productCode: String,
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    back (e) {
      const pages = getCurrentPages()
      const { index } = e.currentTarget.dataset
      const { stepIndex } = this.data
      const delta = stepIndex - (index  === '0' ? -1 : index)
      const list = [
        'pages/home-page/customer-tag/customerTag',
        'pages/home-page/project/project',
        'pages/home-page/appointment/appointment'
      ]
      console.log(pages)
      if (pages.length >= delta && pages[pages.length - delta].route === list[delta]) {
        wx.navigateBack({
          delta
        })
      } else {
        let url = ''
        const { customerId, productId, productCode } = this.data
        switch (index) {
          case '0':
            url = `/${list[index]}?customerId=${customerId}&origin=1`
            break;
          case '1':
            url = `/${list[index]}?customerId=${customerId}&productId=${productId}&productCode=${productCode}`
            break;
          case '2':
            url = `/${list[index]}?customerId=${customerId}&productId=${productId}&productCode=${productCode}&userClassify=learning`
            break;
          default:
            break;
        }
        wx.navigateTo({
          url
        })
      }
    }
  }
})
